import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_demo/demo/token/common/platform/platform_scaffold.dart';

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  final int splashDuration = 2;

  @override
  void initState() {
    super.initState();
    countDownTime();
  }

  countDownTime() async {
    return Timer(Duration(seconds: splashDuration), () {
      /// The SystemChannels statement is used to force the soft keyboard to hide, 
      /// in case some other method or app has left it open blocking your view of 
      /// some of the screen.
      SystemChannels.textInput.invokeMethod('TextInput.hide');
      Navigator.of(context).pushReplacementNamed('/LoginScreen');
    });
  }

  @override
  Widget build(BuildContext context) {
    return PlatformScaffold(
      drawer: Drawer(),
      body: Container(
        decoration: BoxDecoration(color: Colors.black),
        child: Column(
          children: <Widget>[
            Expanded(
              child: Container(
                decoration: BoxDecoration(color: Colors.black),
                alignment: FractionalOffset(0.5, 0.3),
                child: Text(
                  "TestApp", 
                  style: TextStyle(fontSize: 40.0, color: Colors.white),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 30.0),
              child: Text(
                "© Copyright Statement 2018", 
                style: TextStyle(fontSize: 16.0, color: Colors.white,),
              ),
            ),
          ],
        )
      )
    );
  }
}
